-
-
Notifications
You must be signed in to change notification settings - Fork 195
WESTMIDLANDS| ITP-MAY 2025| ROJA ALAGURAJAN| Module Structuring and Testing Data|sprint 2 #612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
WESTMIDLANDS| ITP-MAY 2025| ROJA ALAGURAJAN| Module Structuring and Testing Data|sprint 2 #612
Conversation
const bmi = weightKg / square; | ||
// return the BMI to 1 decimal | ||
return bmi.toFixed(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What type of value do you expect the function to return? A number or a string?
Does your function return the type of value you expect it to return?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cjyuan,
I expect the function to return a number, since BMI is a numeric value used for further analysis, such as comparing it to health category thresholds (e.g., underweight, normal, overweight).
However, in the current version of the function, it returns a string, because the .toFixed(1) method formats the number to 1 decimal place but returns it as a string.
square=(heightM*heightM); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is square
being declared?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cjyuan
In the corrected version of the code, square is declared inside the calculateBMI function using the const keyword:
const square = heightM * heightM;
function formatAs12HourClock(time) { | ||
const [hourStr, minuteStr] = time.split(":"); | ||
let hours = Number(hourStr); | ||
const minutes = minuteStr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just use minuteStr
instead of introducing another variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @cjyuan ,
I have updated and corrected the code based on your feedback. Please take a look and let me know if you have any further suggestions or improvements.
Changes look good! Well done. |
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Completed all mandatory coursework, including:
1.Exercises
2.Error handling tasks
3.Code interpretation and explanation
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.